package com.zmn.oms.business.interfaces.orderamount;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.oms.common.constant.TriggerAmountChangeEnum;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.bo.orderamount.CalcAddOrderAmountDIO;
import com.zmn.oms.model.bo.orderamount.DiscountConditionParamsDIO;
import com.zmn.oms.model.bo.orderamount.OrderDiscountCalcBO;
import com.zmn.oms.model.bo.orderamount.ReCalcOrderAmountDIO;
import com.zmn.oms.model.entity.discount.OrderDiscount;
import com.zmn.oms.model.entity.work.OrderWork;

import java.util.List;

/**
 * 类描述：订单金额计算服务
 *
 * @author heciqi
 * @date 2020/6/3 14:01
 */
public interface OrderDiscountCalcBService {

	/**
	 * 下单
	 * 计算优惠
	 *
	 * @param calcAddOrderAmountDIO
	 * @return
	 */
	OrderDiscountCalcBO calcAddOrderDiscount(CalcAddOrderAmountDIO calcAddOrderAmountDIO, List<OrderDiscount> orderDiscountList);

	/**
	 * 下单后
	 * 重新计算优惠
	 * @param reCalcOrderAmountDIO
	 * @return
	 */
	OrderDiscountCalcBO reCalcDiscount(ReCalcOrderAmountDIO reCalcOrderAmountDIO) throws OmsBaseException;

	/**
	 * 下单后
	 * 重新计算优惠
	 * @param reCalcOrderAmountDIO
	 * @return
	 */
	OrderDiscountCalcBO reCalcDiscountWithNoVerify(ReCalcOrderAmountDIO reCalcOrderAmountDIO) throws OmsBaseException;

	/**
	 * 核销优惠
	 *
	 * @param orderDiscounts
	 * @param orderWork
	 * @param compulsoryFlag 是否强制验券，1否，2是
	 * @return
	 */
	Integer receiptConsumeDiscount(List<OrderDiscount> orderDiscounts, Integer invoker, Integer originalAmount, OrderWork orderWork, Integer compulsoryFlag,String thrShopId,String shopPhone) throws OmsBaseException;

	/**
	 * 获取第三方验券的售价（获取售价后DMS队列通知到OMS更新售价）
	 * @param orderId
	 * @param cityId
	 * @param channelId
	 * @param itemCode
	 */
	void getThirdSellAmount(Long orderId, Integer cityId, Integer channelId, String itemCode);

	/**
	 * 归还优惠
	 * @param orderDiscounts
	 */
	void backDiscount(List<OrderDiscount> orderDiscounts);

	/**
	 * 作废优惠
	 * @param orderDiscounts 优惠列表
	 * @return
	 */
	void obsDiscount(List<OrderDiscount> orderDiscounts);

	/**
	 * 作废优惠
	 * @param itemCodes 券码列表
	 * @return
	 */
	void obsDiscountItemCodes(List<String> itemCodes, Long orderId);

	/**
	 * 获取渠道优惠
	 * @param discountConditionParamsDIO
	 * @param discountAmount 优惠金额
	 * @param discounts 已有优惠
	 * @return
	 */
	OrderDiscountCalcBO getChannelDiscount(DiscountConditionParamsDIO discountConditionParamsDIO, Integer discountAmount, List<OrderDiscount> discounts);

	/**
	 * 生成特殊优惠券
	 * @param orderId
	 * @param userId
	 * @param discountAmount
	 * @return 券码
	 */
	String generateCouponDiscount(Long orderId, Long userId, Integer discountAmount, Integer bathId) throws OmsBaseException;

	/**
	 * 获取人工优惠
	 * @param triggerAmountChangeEnum
	 * @param calcOrderAmountDIO
	 * @return
	 * @throws OmsBaseException
	 */
	OrderDiscountCalcBO getArtificialDiscount(TriggerAmountChangeEnum triggerAmountChangeEnum, ReCalcOrderAmountDIO calcOrderAmountDIO) throws OmsBaseException;

	/**
	 * 返回迟到补偿金额
	 *
	 * @return
	 */
	Integer getLateAmount(Long orderId, Integer activeId);

	/**
	 * 获取最大优惠金额
	 * @param triggerAmountChangeEnum
	 * @param calcOrderAmountDIO
	 * @return
	 */
	Integer getArtificialMaxDiscount(TriggerAmountChangeEnum triggerAmountChangeEnum, ReCalcOrderAmountDIO calcOrderAmountDIO) throws OmsBaseException;

	/**
	 *
	 * @param triggerAmountChangeEnum
	 * @param calcOrderAmountDIO
	 * @throws OmsBaseException
	 */
	Integer getPromId(TriggerAmountChangeEnum triggerAmountChangeEnum, ReCalcOrderAmountDIO calcOrderAmountDIO) throws OmsBaseException;

	/**
	 * 检测人工优惠
	 * @param calcOrderAmountDIO
	 * @return
	 */
	ResponseDTO<Boolean> checkArtificialDiscount(ReCalcOrderAmountDIO calcOrderAmountDIO);

	/**
	 * 获取删除人工优惠后的优惠
	 * @param orderDiscountList
	 * @return
	 */
	OrderDiscountCalcBO getDeleteArtificialDiscount(List<OrderDiscount> orderDiscountList);

	/**
	 * 获取仅删除人工优惠后的价格，不包括特殊优惠
	 * @param orderDiscountList
	 * @return
	 */
	OrderDiscountCalcBO getDeleteMaterArtificialDiscount(List<OrderDiscount> orderDiscountList);

	/**
	 * 获取删除所有的优惠后的优惠（渠道优惠例外）
	 * @param orderDiscountList
	 * @return
	 */
	OrderDiscountCalcBO getDeleteAllDiscount(List<OrderDiscount> orderDiscountList, Integer fullPaymentFlag);

	/**
	 * 检测是否配置了迟到补偿优惠
	 * @return
	 */
	boolean checkLateCompensationDiscount(Integer cityId, Integer channelId, Integer showProductId);

	/**
	 * 删除redis特殊优惠券
	 * @param orderId
	 */
	void delRedisSpecialDiscountCoupon(Long orderId);


}
